<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<%@ include file="/WEB-INF/views/include/head.jsp"%>
    <title>大货服装款式</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
	<c:set var = "order10" value="<%=ResourcesUtil.getConfig(\"order_flag-normal_10\") %>"/>
	<c:set var = "order20" value="<%=ResourcesUtil.getConfig(\"order_flag-express_20\") %>"/>
    <script>
 	// 检索按钮实装方法
	function searchListForm() {
		
		var sOrderNo = $("#orderNO").val();	
		var contractNo = $("#contractNo").val();	
		var shirtSgd = $("#shirtSgd").val();
		var sBeginDate = $("#beginDate").val();	
		/* var sEndDate = $("#endDate").val();	 */
		var sOrderStatusCD = $("#orderStatusCD").val();
		var operating3Status = $("#operating3Status").val();
		var styleNoFrom = $("#styleNoFrom").val();
		var styleNoTo = $("#styleNoTo").val();
		$("#activity_pane").showLoading();
		$.post("${ctx}/customization/order/searchList?orderNO="+sOrderNo + "&contractNo=" +contractNo
				+ "&shirtSgd=" +shirtSgd + "&beginDate="+sBeginDate + "&orderStatusCD="+sOrderStatusCD
				+ "&styleNoFrom="+styleNoFrom + "&styleNoTo="+styleNoTo + "&operating3Status="+operating3Status, "", function(result) {
			var listHtml = result["order"];
			var pageHtml = result["page"];
			$("#listHtml").html(listHtml);
			$("#paging").html(pageHtml);
			$("#activity_pane").hideLoading();
		}, 'json');
	} 
 	//插入内部订单号 
 	function insertStyleNo(){
		$.post("${ctx}/customization/order/insertTempTable", "", function() {
			searchListForm();
		}, 'json');
 	}
	// 导出
	function exportExcel() {
		$("#activity_pane").showLoading();
		var contractID = "${order.contractID}";
		$.post("${ctx}/customization/order/exportOrder?contractID="+contractID, "", function(result) {
			var sk = result["FLG"];
			if (sk == "OK") {
				window.location.href='${ctx}/customization/order/excelDownload';
				$("#activity_pane").hideLoading();
			} else {
				alert("导出失败，请重新导出。");
				$("#activity_pane").hideLoading();
			}

		}, 'json');
	}
	
	// 导出费用
	function exportCostExcel() {
		$("#activity_pane").showLoading();
		var contractNo = $("#contractNo").val();
		$.post("${ctx}/customization/order/exportContractCostDetails?contractNo="+contractNo, "", function(result) {
			if (result == "true") {
				window.location.href='${ctx}/customization/order/makeCostExcelFile?contractNo='+contractNo;
			} else if (result == "error") {
				alert("导出失败，请重新导出。");
			}else{
				alert("合同号对吗？！");
			}
			$("#activity_pane").hideLoading();
		}, 'json');
	}
	
	/* // 导出
	function exportUnit() {
		$("#activity_pane").showLoading();
		var orderNO = $('#orderNO').val();
		var beginDate = $("#beginDate").val();
		var endDate = $("#endDate").val();
		var shirtSgd = $("#shirtSgd").find("option:selected").val();
		var orderStatusCD = $("#orderStatusCD").find("option:selected").val();
		window.location.href='${ctx}/customization/order/exportFile?shirtSgd='+shirtSgd+'&beginDate='+beginDate+'&endDate='+endDate+'&insideOrderNO='+orderNO+'&orderStatusCD='+orderStatusCD;
		$("#activity_pane").hideLoading();
	} */
	
	// 导出
	function exportTGDetail() {
		$("#activity_pane").showLoading();
		/* var orderNo = $('#orderNO').val();
		var beginDate = $("#beginDate").val();
		var endDate = $("#endDate").val();
		var shirtSgd = $("#shirtSgd").find("option:selected").val();
		var orderStatusCD = $("#orderStatusCD").find("option:selected").val();
		var styleNo = $("#styleNo").val(); */
		$.post('${ctx}/customization/order/backstage', "", function(result) {
			/* var flg = result["flg"]
			var list = result["list"] */
			if (result == "cloud") {
				window.location.href='${ctx}/customization/order/exportTransportGoodsDetail';
				$("#activity_pane").hideLoading();
			} else {
				alert("导出失败，请重新导出。");
				$("#activity_pane").hideLoading();
			}
		}, 'json');
	}
	
	
	//重置
	function clean() {
		$("input").val("");
		
		$('#orderNO').val('');
        $("#customerName").val('');
        $("#beginDate").val('');
        /* $("#endDate").val(''); */
        $("#orderStatusCD").val('');
        $("#orderStatusCD").select2();
        $("#operating3Status").val('');
        $("#operating3Status").select2();
		$("#shirtSgd").val('');
		$("#shirtSgd").select2();
        searchListForm();
	}
        // 全选
        function chooseAll(item) {
          if (item.checked || item.checked == "true") {
        	$("[name='ids']").prop("checked",true);
          } else {
        	  $("[name='ids']").prop("checked",false);//取消全选
          }
        }
        //标记修改
		function changeValue(urgentCD,orderNO) {
			var r=confirm("确定要修改吗?")
			var order10 = "${order10}";
			var order20 = "${order20}";
			if (r == true){
				if (urgentCD == order10 )
				{
					var params = {urgentCD:order20,orderNO:orderNO};
					$.post("${ctx}/customization/order/updateUrgentCd",params,function (result) {
						if(result == "true"){
							tipParent("修改成功");
							searchListForm();
						}else{
							tipParent("修改失败!");
						}
					});

				}else if(urgentCD == order20){
                    var params = {urgentCD:order10,orderNO:orderNO};
                    $.post("${ctx}/customization/order/updateUrgentCd",params,function (result) {
						if(result == "true"){
							tipParent("修改成功");
							searchListForm();
						}else{
							tipParent("修改失败!");
						}
                    });
			}
		}
     }
        //更新状态 
        function updateStatus() {
        	var beginDate = $("#beginDate").val();
        	var contractNo = $("#contractNo").val();
        	var orderNO = $("#orderNO").val();
        	var shirtSgd = $("#shirtSgd").find("option:selected").val();
        	var orderStatusCD = $("#orderStatusCD").find("option:selected").val();
        	var styleNoFrom = $("#styleNoFrom").val();
        	var styleNoTo = $("#styleNoTo").val();
        	var url = "?beginDate="+beginDate+"&contractNo="+contractNo+"&orderNO="+orderNO+"&shirtSgd="+shirtSgd+"&orderStatusCD="+orderStatusCD+"&styleNoFrom="+styleNoFrom+"&styleNoTo="+styleNoTo;
        	popup("500px","400px","${ctx}/customization/order/updateStatus"+url);
        	
		}
    </script>
</head>
<body>

    <div class="listArea" id="activity_pane" >		
		<c:set value="<%=ResourcesUtil.getConfig(\"order_status\")%>" var="orderStatus" />		
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
			<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
			<div class="listBg" >
				<div class="searchArea clearfix">
					<div class="searchLeft clearfix" style="width: 1350px;">
		                <div class="searchInp clearfix">
		                    <!-- 交货日期 -->
		                    <p class="searchTxt" style="width: 60px;"><spring:message code="order_targetDate"/></p>
		                    <div class="timeBox">
							<input type="text" class="laydate-icon" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"
								id="beginDate" name="beginDate" style="width: 110px" value="">
							<%-- <p class="list">~</p>
							<input type="text" class="laydate-icon" id="endDate" name="endDate"
								style="width: 110px" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})" value="${fns:getDate('yyyy-MM-dd')}"> --%>
						    </div>
		                </div>
		                <div class="searchInp clearfix">
		                    <!-- 合同号 -->
		                    <p class="searchTxt" style="width: 60px;"><spring:message code="order_contractNo"/></p>
		                    <input class="w-customer" style="width: 120px;"  id="contractNo"  name="contractNo" value="${order.contractNo }">
		                </div>
		                <div class="searchInp clearfix">
		                    <!-- 订单号 -->
		                    <p class="searchTxt" style="width: 60px;"><spring:message code="order_orderNo"/></p>
		                    <input class="w-customer"  id="orderNO"  name="orderNO">
		                </div>
		                <div class="searchInp clearfix">
							<!--线号-->
							<p class="searchTxt" style="width: 50px;"><spring:message code="oder_matrial_xianhao" /></p>
                                <select id="shirtSgd" name="shirtSgd" style="width:80px;">
                                  <option value="" selected = "selected"><spring:message code="CompanyUser_pleaseChoose"/></option>
                                <c:forEach items="${designOptionList}" var="item">
                                    <option value="${item.itemValue}" >
                                            ${item.itemNameCN}
                                    </option>
                                </c:forEach>
                                </select>
		                </div>
		                <div class="searchInp clearfix">
		                    <!-- 状态 -->
		                    <p class="searchTxt" style="width: 50px;"><spring:message code="order_state"/></p>
			                <select id="orderStatusCD" name="orderStatusCD" style="width:80px;">
		                      <option value="" selected = "selected"><spring:message code="CompanyUser_pleaseChoose"/></option>
							  <c:forEach items="${fns:getDictList('PRODUCTION_STATUS')}" var="item">
                                    <option <c:if test="${fn:split(order.orderStatusCD,'-')[1] eq item.itemValue}">selected="selected"</c:if> value="${item.itemCode}-${item.itemValue}" > 
                                        ${item.itemName}
                                    </option>
                                </c:forEach>
		                    </select>
		                    <!-- <input class="w-customer"  id="orderStatusCD"  name="orderStatusCD"> -->
		                </div> 
		                <div class="searchInp clearfix">
		                    <!-- 裁剪状态 -->
		                    <p class="searchTxt" style="width: 60px;">裁剪状态</p>
			                <select id="operating3Status" name="operating3Status" style="width:80px;">
		                      <option value="" selected = "selected"><spring:message code="CompanyUser_pleaseChoose"/></option>
							  <c:forEach items="${fns:getDictList('OPERATING_STATUS')}" var="item">
                                    <option <c:if test="${fn:split(order.orderStatusCD,'-')[1] eq item.itemValue}">selected="selected"</c:if> value="${item.itemCode}-${item.itemValue}" > 
                                        ${item.itemName}
                                    </option>
                                </c:forEach>
		                    </select>
		                    <!-- <input class="w-customer"  id="orderStatusCD"  name="orderStatusCD"> -->
		                </div> 
		                <div class="searchInp clearfix">
		                    <!-- 生产号 -->
		                    <p class="searchTxt" style="width: 60px;"><spring:message code="style_neibu_no"/></p>
		                    <div class="timeBox">
		                   <input class="w-customer"  id="styleNoFrom"  name="styleNoFrom"><p class="list">~</p><input class="w-customer"  id="styleNoTo"  name="styleNoTo">
		                
		                </div>
            		</div></div>
		            <div class="searchRight searchRightLg">
		            	<c:if test="${order.imageFlag == 'customizationContract' }">
		            	<!-- 返回上一页 -->
		                <button type="button" class="btn-js" style="width: 70px;"  onclick="window.location.href='${ctx}/customization/contract/'">返回</button>
		            	</c:if>
		            	<!-- 更新状态 -->
		            	<shiro:hasPermission name="customization:order:edit">
							<button type="button" class="btn-js"  onclick="updateStatus();"><spring:message code="order_update_status"/></button>
		            	</shiro:hasPermission>
		            	<%-- <!-- 导入 -->
		                <button type="button" class="btn-js"  onclick="popup('500px','340px','${ctx}/customization/order/uploadExcelFile');"><spring:message code="order_holland_dao_ru"/></button> --%>
						<!-- 导出 -->
						<shiro:hasPermission name="customization:order:view">
							<button type="button" class="btn-js"  onclick="exportCostExcel()">导出费用</button>
						</shiro:hasPermission>
		                <!-- 导出费用 -->
						<shiro:hasPermission name="customization:order:view">
							<button type="button" class="btn-js"  onclick="exportExcel()"><spring:message code="order_gongxu_daochu"/></button>
						</shiro:hasPermission>
						<%-- <!-- 导出 -->
						<button type="button" class="btn-js"  onclick="exportUnit();"><spring:message code="order_danhao_daochu"/></button> --%>
						<%-- <!-- 导出 -->
						<button type="button" class="btn-js"  onclick="exportTGDetail();"><spring:message code="order_exprot_transport"/></button> --%>
		                <!-- 重置 -->
		                <button type="button" class="btn-js" style="width: 70px;"  onclick="clean()"><spring:message code="common_reset"/></button>
		                <!-- 检索 -->
		                <button type="button" class="btn-js" style="width: 70px;" onclick = "searchListForm();"><spring:message code="commom_check"/></button>
		            </div>
					<form id="personalReport"></form>
    			</div>
			    <div class="tableArea">
				<div class="tableScrollSm" style="overflow: auto;width: 1970px;height: 740px; ">
						<table cellpadding="0" class="tableHead">
							<thead>
			                    <tr>
			                        <!-- checkBox 
			                        <th><input type="checkbox"  style="height:auto;" onclick="chooseAll(this)"></th>-->
			                        <!-- No. -->
			                        <th><p class="table-No"><spring:message code="order_No" /></p></th>
			                        <!-- 标记 -->
			                        <th><p class="width-50px"><spring:message code="order_mark" /></p></th>
									<!-- 类别 -->
									<th><p class="width-70px"><spring:message code="contract_edit_styleType" /></p></th>
									<!-- 合同号 -->
									<th><p class="width-125px"><spring:message code="order_contractNo" /></p></th>
									<!-- 内部款号 -->
									<th><p class="width-125px"><spring:message code="style_neibu_no" /></p></th>
			                        <!-- 订单号 -->
									<th><p class="width-125px"><spring:message code="order_orderNo" /></p></th>
			                        <!-- 款式名称 -->
			                        <th><p class="width-120px"><spring:message code="order_style_name" /></p></th>
			                        <!-- 面料号 -->
			                        <th><p class="width-200px"><spring:message code="order_matrial_no" /></p></th>
			                        <!-- 规格 -->
			                        <th><p class="width-80px"><spring:message code="oder_matrial_guige" /></p></th>
			                        <!-- 线号 -->
		                            <th><p class="width-90px"><spring:message code="oder_matrial_xianhao" /></p></th>
		                            <!-- 线色 -->
		                            <th><p class="width-140px"><spring:message code="oder_matrial_xianse" /></p></th>
		                            <!-- 刺绣 -->
		                            <th><p class="width-90px"><spring:message code="oder_matrial_smt" /></p></th>
		                            <!-- 面料成分 -->
		                            <th><p class="width-90px"><spring:message code="order_matrial_chengfen" /></p></th>
		                            <!-- 船期 -->
		                            <th><p class="width-100px"><spring:message code="order_chuanqi" /></p></th>
		                            <!-- 加工日期 -->
		                            <th><p class="width-100px"><spring:message code="order_jiagong_riqi" /></p></th>
									<!-- 交货日期 -->
									<th><p class="width-100px"><spring:message code="order_jiaohuo_riqi" /></p></th>
		                            <!-- 经过天数 -->
		                            <th><p class="width-50px"><spring:message code="order_jingguo_tianshu" /></p></th>
		                            <!-- 费用 -->
		                            <th><p class="width-80px"><spring:message code="order_jingguo_cost" /></p></th>
		                            <!-- 订单状态 -->
		                            <th><p class="width-70px"><spring:message code="order_status" /></p></th>
		                            <!-- 裁剪状态 -->
		                            <th><p class="width-70px">裁剪状态</p></th>
		                        </tr>
		                    </thead>
			            </table>
			            <table cellpadding="0" class="tableBody">
							<tbody  id = "listHtml"></tbody>
						</table>
            		</div>
			</div>
			 </div>
            <div id = "paging" ></div>
   </div>
    <script>
    $(document).ready(function(){
    	var imageFlag = "${order.imageFlag}";
    	/* if (imageFlag == 'customizationContract' ) {
    		$("#beginDate").val("${order.contractDate}");
    		$("#endDate").val("${order.contractDate}");
		} */
        $("select").select2();
    	searchListForm();
    	
    	});
	</script>
</body>
</html>